home *** CD-ROM | disk | FTP | other *** search
/ amalnet.k12.il / www4.amalnet.k12.il.tar / www4.amalnet.k12.il / Fix buffer overrun Office 2003 _heb.rar / MicrosoftFixit50255.msi / Binary.HEBREWSCRIPT < prev    next >
Text File  |  2009-11-02  |  3KB  |  93 lines

  1. '
  2. ' steps:
  3. '   look in Application data folder\Microsoft\Proof for .dic files
  4. '   rename all .dic files to .old
  5. '   copy the contents of 
  6.  
  7. option explicit
  8.  
  9. ' reference:
  10. '    http://www.microsoft.com/technet/scriptcenter/guide/sas_fil_higv.mspx?mfr=true
  11. const APPLICATION_DATA_INDEX = &H1a&
  12. const ForReading             = 1
  13. const ForWriting             = 2
  14.  
  15. dim oShellApp
  16. dim oFileSys
  17. dim oShell
  18. dim oFolder
  19. dim oFolderItem
  20. dim strProofDir
  21. dim oFileList
  22. dim oFile
  23.  
  24. set oShellApp   = CreateObject("Shell.Application")
  25. set oFileSys    = CreateObject("Scripting.FileSystemObject")
  26. set oShell      = CreateObject("WScript.Shell")
  27.  
  28. Set oFolder     = oShellApp.Namespace(APPLICATION_DATA_INDEX)
  29. Set oFolderItem = oFolder.Self
  30. strProofDir     = oFolderItem.Path & "\Microsoft\Proof"
  31.  
  32. ' make sure directory exists
  33. if (oFileSys.FolderExists (strProofDir)) then
  34.     Set oFolder     = oFileSys.GetFolder(strProofDir)  
  35.     Set oFileList   = oFolder.Files
  36.  
  37.     dim basename
  38.     dim fullname
  39.     dim extension
  40.     dim tempfilepath
  41.     
  42.     dim registryValues
  43.     registryValues = ""
  44.     
  45.     dim fileCount
  46.     fileCount = 0
  47.     
  48.     ' loop through all the files in the folder
  49.     For each oFile In oFileList 
  50.         basename   = oFileSys.GetBaseName(oFile)
  51.         fullname   = oFileSys.GetFileName(oFile)
  52.         extension  = oFileSys.GetExtensionName(oFile)
  53.         
  54.         ' move the existing dictionary files to a .old extension
  55.         dim oldFilename 
  56.         oldFilename = strProofDir & "\" & basename & ".OLD"
  57.         
  58.         If UCase(extension) = "DIC" Then
  59.             
  60.             ' if a .old already exists, then delete it
  61.             if oFileSys.FileExists(oldFilename) then
  62.                 oFileSys.DeleteFile oldFilename
  63.             end if
  64.             
  65.             ' move to a .old extension
  66.             oFileSys.MoveFile strProofDir & "\" & fullname, oldFilename
  67.         
  68.             dim oldFileHandle
  69.             dim newFileHandle
  70.             dim tempLine
  71.  
  72.             ' if we had a dictionary file, then read its contents and create a new dictionary file
  73.             if oFileSys.FileExists(oldFilename) then
  74.                 
  75.                 set oldFileHandle = oFileSys.OpenTextFile(oldFilename, ForReading, True)  
  76.                 set newFileHandle = oFileSys.CreateTextFile(strProofDir & "\" & basename & ".DIC", True)
  77.                 
  78.                 Do While Not oldFileHandle.AtEndofStream
  79.                     tempLine = oldFileHandle.ReadLine
  80.                     newFileHandle.WriteLine tempLine
  81.                 Loop 
  82.                 
  83.                 newFileHandle.Close
  84.                 oldFileHandle.Close
  85.                 
  86.                 ' update registry 
  87.                 fileCount = fileCount + 1
  88.                 oShell.RegWrite "HKCU\Software\Microsoft\Shared Tools\Proofing Tools\Custom Dictionaries\" & fileCount, strProofDir & "\" & basename & ".DIC"
  89.             end if
  90.         end if
  91.     Next
  92. end if
  93.